import React from "react"
import { configure } from "mobx"
import LoginStore from "./login.Store"
import UserStore from "./user.Store"
import MenuStore from "./menu.Store"
import OperateStore from "./operate.Store"
import ModifyStore from "./modify.Store"

configure({
  enforceActions: "never",
})

class RootStore {
  // 组合模块
  constructor() {
    this.loginStore = new LoginStore()
    this.userStore = new UserStore()
    this.menuStore = new MenuStore()
    this.operateStore = new OperateStore()
    this.modifyStore = new ModifyStore()
  }
}
// 导入useStore方法供组件使用数据
const StoresContext = React.createContext(new RootStore())
export const useStore = () => React.useContext(StoresContext)